package org.itboys.basetemplate.service;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import javax.annotation.Resource;

import org.itboys.basetemplate.entity.TravelNoteCat;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseService;
import org.springframework.stereotype.Service;

/**
 * 游记类型
 */
@Service
public class TravelNoteCatService extends BaseService<TravelNoteCat, Long>{

	private static final long serialVersionUID = 1L;

	@Resource(name = "memberDS")
	private MongoDataSource ds;
	
	@Override
	protected MongoDataSource getMongoDataSource() {
		return ds;
	}
	/**
	 * 更新操作
	 * @param entity
	 * @return
	 */
	public <T> void modifyNotNull(TravelNoteCat bean){
		Field[] Fields = bean.getClass().getDeclaredFields();
		TravelNoteCat data = getById(bean.getId());
		try {
			for (Field field : Fields)
			{
				if (!Modifier.isFinal(field.getModifiers()))
				{
					field.setAccessible(true);
					if (field.get(bean) != null /*&& !field.get(bean).toString().equals("")*/)
					{
						field.set(data, field.get(bean));
					}

				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} 
		super.update(data);
	}
}
